package com.canton.dao.utils;

import org.springframework.stereotype.Component;

/**
 * @Author: Sure
 * @Date: 2022-04-27 16:27
 */
@Component

public class CypherUtils {
    public static String createSingle(String entity){
        return "merge (m:Person{name:\""+entity+"\"}) return m";
    }

    public static String createRelationByTwoNodes(String entityFrom,String relation,String entityTo){
        return "match(m:Person{name:\""+entityFrom+"\"}),(n:Person{name:\""+entityTo+"\"}) merge (m)-[r:"+relation+"]->(n) return m,n,r";
    }

    public static String searchAll(String entityName){
        if(entityName == "" || entityName == null){
            return "match (m)-[edge]->(n) return m,edge,n";
        }

        return "match (m)-[edge]-(n) where n.名称='" + entityName + "' return m,edge,n";
    }


}
